Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2MiniBase = require("MiniBase");
var $2ServerConfig = require("ServerConfig");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2KS_VideoMgr = require("KS_VideoMgr");
var $2KS_RecorderManager = require("KS_RecorderManager");
var $2Platformconf = require("Platformconf");
var $2GameUser = require("GameUser");
var $2KS_InterstitialMgr = require("KS_InterstitialMgr");
var u = window.ks;
exports.default = /* */function (_o$default) {
  function _class18() {
    var _this49;
    babel_classCallCheck(this, _class18);
    _this49 = _callSuper(this, _class18);
    _this49.key_maxDistance = "maxDistance";
    _this49.key_countDistance = "countDistance";
    _this49.loadingShow = false;
    _this49.getSystemInfo = function () {};
    _this49.active = !!u;
    console.log("快手小游戏1");
    return _this49;
  }
  babel_inherits(_class18, _o$default);
  return babel_createClass(_class18, [{
    key: "init",
    value: function init(e) {
      if (u && u.eqapi) {
        var _e27 = $2Platformconf.default.eqconfig();
        _e27.getToken = "getToken";
        _e27.onLoginned = function (e) {
          console.log("onLoginned: 回调接收值", e);
          "" == $2GameUser.default.getInstance().openid && ($2GameUser.default.getInstance().openid = e.uid);
          $2GameUser.default.getInstance().id = e.id;
          $2GameUser.default.getInstance().uid = e.uid;
        };
        console.log("ks_eq-init", _e27);
        u.eqapi.init(_e27);
      }
      var t = u.getLaunchOptionsSync();
      $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONSHOW, t);
      u.onShow(function (e) {
        $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONSHOW, e);
      });
      u.onHide(function (e) {
        $2EventCenter.default.postWaitEvent($2EventDefine.default.EVENT_ONHIDE, e);
      });
      window.kwaigame && window.kwaigame.readyGo();
      this.eqInit();
    }
  }, {
    key: "setClipboardData",
    value: function setClipboardData(e) {
      u.setClipboardData && u.setClipboardData({
        data: e,
        success() {},
        fail(e) {
          console.log("setClipboardData调用失败", e);
        }
      });
    }
  }, {
    key: "eqInit",
    value: function eqInit() {
      u.eqRegisterHandler(function (e) {
        console.log("++++++++++++++", JSON.stringify(u.eqGetConfig()));
        $2ServerConfig.default.getInstance().init(e);
      });
    }
  }, {
    key: "eqIsAuthoried",
    value: function eqIsAuthoried() {
      return u.eqIsAuthoried();
    }
  }, {
    key: "login",
    value: function login(e) {
      u.eqLogin({
        success(t) {
          console.log("eq login success ", JSON.stringify(t));
          var n = {
            id: t.id,
            openid: t.openId,
            nickName: t.userName,
            avatarUrl: t.userHead
          };
          console.log("currentgame.eqGetConfig() ", JSON.stringify(n));
          e(true, n);
        },
        fail(t) {
          console.log("eq login fail ", JSON.stringify(t));
          var n = u.eqGetConfig();
          var o = {
            userinfo: {
              id: n.userinfo.id,
              openid: n.userinfo.openId,
              nickName: "",
              avatarUrl: ""
            }
          };
          n.userinfo.userinfo.userName && (o.userinfo.nickName = n.userinfo.userinfo.userName);
          n.userinfo.userinfo.userHead && (o.userinfo.avatarUrl = n.userinfo.userinfo.userHead);
          e(false, o);
        }
      });
    }
  }, {
    key: "checkSession",
    value: function checkSession(e) {
      e(true);
    }
  }, {
    key: "checkFollowAwemeState",
    value: function checkFollowAwemeState(e) {
      if (u && u.checkFollowState) {
        u.checkFollowState({
          accountType: "CPServiceAccount",
          callback(t) {
            console.log("checkFollowState", JSON.stringify(t));
            if (1 == t.hasFollow) {
              e(true);
            } else {
              e(false);
            }
          }
        });
      } else {
        e(true);
      }
    }
  }, {
    key: "checkShortcut",
    value: function checkShortcut(e) {
      console.log("快手 checkShortcut");
    }
  }, {
    key: "openAwemeUserProfile",
    value: function openAwemeUserProfile(e) {
      if (u && u.openUserProfile) {
        console.log("注册EVENT_CHECKFOLLOW");
        u.openUserProfile({
          accountType: "CPServiceAccount",
          callback(e) {
            console.log("openUserProfile", JSON.stringify(e));
          }
        });
      } else {
        e(true);
      }
    }
  }, {
    key: "play_AD",
    value: function play_AD(e, t) {
      var n = $2Platformconf.default.Instance.getconfig().KWaiGame.video[0];
      $2KS_VideoMgr.default.Instance.playvideo(n, e);
    }
  }, {
    key: "vibrate",
    value: function vibrate() {
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
    }
  }, {
    key: "onPostMessage",
    value: function onPostMessage(e) {
      console.log("onPostMessage");
      u.getOpenDataContext().postMessage(e);
    }
  }, {
    key: "request",
    value: function request(e, t, n) {
      u.request({
        url: e,
        method: "POST",
        data: t,
        success(e) {
          n && n(e);
        },
        fail(e) {
          n && n(e);
        }
      });
    }
  }, {
    key: "shareDiyMap",
    value: function shareDiyMap(e, t) {}
  }, {
    key: "recorderStart",
    value: function recorderStart() {
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 280;
      console.log("ks 录频开始");
      $2KS_RecorderManager.KS_RecorderManager.getInstance().start(e);
    }
  }, {
    key: "recorderStop",
    value: function recorderStop() {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().stop();
    }
  }, {
    key: "recorderPause",
    value: function recorderPause() {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().pause();
    }
  }, {
    key: "recorderResume",
    value: function recorderResume() {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().resume();
    }
  }, {
    key: "shareAppMessage",
    value: function shareAppMessage(e, t) {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().shareAppMessage(e, t);
    }
  }, {
    key: "navigateToVideoView",
    value: function navigateToVideoView(e) {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().navigateToVideoView(e);
    }
  }, {
    key: "requestVideos",
    value: function requestVideos(e, t) {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().request(e, t);
    }
  }, {
    key: "shareVideo",
    value: function shareVideo(e) {
      $2KS_RecorderManager.KS_RecorderManager.getInstance().shareVideo(e);
    }
  }, {
    key: "getAppName",
    value: function getAppName(e) {
      u.getSystemInfo({
        response(t) {
          console.log("获取系统信息:" + JSON.stringify(t));
          if (t.appName) {
            e(t.appName);
          } else {
            t.environment && e(t.environment);
          }
        }
      });
    }
  }, {
    key: "interstitialShow",
    value: function interstitialShow(e) {
      console.log("interstitialShow", e);
      var t = "";
      t = e ? $2Platformconf.default.Instance.getconfig().KWaiGame.Interstitial[e] : $2Platformconf.default.Instance.getconfig().KWaiGame.Interstitial[0];
      console.log(" ks_InterstitialMgr show", t);
      $2KS_InterstitialMgr.default.Instance.show(t);
    }
  }, {
    key: "addShortcut",
    value: function addShortcut(e) {
      if (window.ks) {
        window.ks.addShortcut({
          success() {
            console.log("添加桌面成功");
          },
          fail(e) {
            if (-10005 === e.code) {
              console.log("暂不支持该功能");
            } else {
              console.log("添加桌面失败", e.msg);
            }
          }
        });
      } else {
        e(true);
      }
    }
  }]);
}($2MiniBase.default);